﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BE.Web.Betfair.Interface.Entities;
using System.Collections.ObjectModel;
using System.Diagnostics.Contracts;

namespace BE.Web.Betfair.Interface.Requests
{
    /// <summary>
    /// Represents a request for retrieving betevents by a given event Type.
    /// </summary>
    public sealed class BetEventByTypeRequest : SessionBasedRequest<ReadOnlyCollection<BetEvent>>
    {
        [ContractInvariantMethod]
        void ObjectInvariant()
        {
            Contract.Invariant(this.EventType != null);
            Contract.Invariant(this.Session != null);
        }

        /// <summary>
        /// Gets the type of the event which should be resolved.
        /// </summary>
        /// <value>The type of the event.</value>
        public BetEventType EventType { get; private set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="BetEventByTypeRequest"/> class.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="completedAction">The completed action.</param>
        /// <param name="eventType">The Eventtype for which the events should be retrieved</param>
        public BetEventByTypeRequest(BetEventType eventType, Session session,Action<ReadOnlyCollection<BetEvent>> completedAction) :
            base(session,completedAction)
        {
            #region conditions
            Contract.Requires<ArgumentNullException>(session != null);
            Contract.Requires<ArgumentNullException>(completedAction != null);
            Contract.Requires<ArgumentNullException>(eventType != null);
            Contract.Ensures(this.EventType != null);
            Contract.Ensures(this.Session != null);
            #endregion

            this.EventType = eventType;
        }
    }
}
